<template>
  <view>
    <navBar v-if="isShowCustomNavBar" :navbarData.sync="navbarData"></navBar>
    <view class="contentBox">
      <view class="pageTitle">您已登记成功</view>
      <view class="textBox">结果将在{{params.promulgateTime}}公布，请您关注微信服务消息</view>
      <view class="textBox mb46">【活动参与结果通知】</view>
      <view class="stextBox">
        <label class="bold">特别说明：</label>提交抽签购活动的登记申请并不代表获得购买资格，也不构成您和我们订立相关商品购买合同的要约或者承诺，您的登记申请提交后不能确保一定能够成功通过并获取购买资格。
      </view>
      <view class="imgBox">
        <image :src="params.url" mode="widthFix"></image>
      </view>
      <view class="imgTitle">
        {{params.itemName}}
      </view>
    </view>
    <view class="btnBox" v-if="!params.disableShare">
      <button class="item button" open-type="share">
        <view class="icon">
          <image src="https://100000063-1252208446.file.myqcloud.com/images/miniprogram/icon/icon_weixin.png"
            mode="widthFix"></image>
        </view>
        <view class="fontTo">发送好友</view>
      </button>
      <view class="item" @click="skipShare">
        <view class="icon">
          <image src="https://100000063-1252208446.file.myqcloud.com/images/miniprogram/icon/icon_share.png"
            mode="widthFix"></image>
        </view>
        分享海报
      </view>
    </view>
    <view class="bottomBtn" :class="[isIpx ? 'fix-iphonex-button' : '']">
      <view class="btn100" @click="skipMore">
        探索更多臻品
      </view>
    </view>
  </view>
</template>

<script>
  import api from '@/api/api';
  import NavBar from '@/components/common/navbar';

  export default {
    data() {
      return {
        isShowCustomNavBar: true,
        // 组件所需的参数
        navbarData: {
          showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
          navbarTitle: '登记成功' //导航栏 中间的标题
        },
        params: {},
        isIpx: false,
        nowPages:'',
      }
    },
    components: {
      navBar: NavBar
    },
    onLoad(options) {
      this.params = JSON.parse(decodeURIComponent(options.option))
      let systemInfo = uni.getSystemInfoSync();
      let isIpx = systemInfo.model.indexOf('iPhone X') !== -1 || systemInfo.model.indexOf('iPhone1') !== -1 ||
        systemInfo.model.indexOf('unknown<iPhone13') !== -1;
      this.isIpx = isIpx;
      if(this.params.disableShare){
        uni.hideShareMenu()
      }
      let pages = getCurrentPages();
      var currPage = pages[pages.length - 1];
      this.nowPages = currPage.route;
    },
    onShow() {
      let that = this;
      getApp().cl_tracker.track('mini_program_view', {
            path:  this.nowPages,
            pageName: '登记成功',
          })
    },
    methods: {
      skipShare() {
        let options = JSON.stringify(this.params)
        uni.navigateTo({
          url: '/pages/item/itemShare?params=' + encodeURIComponent(options)
        })
      },
      skipMore() {
        uni.reLaunch({
          url: '/pages/home/home'
        })
        // if(api.environment == 'formal') {
        //   uni.reLaunch({
        //     url:'/pages/item/search?cateCode=16730&title=不凡甄选&navId=9398'
        //   })
        // } else if(api.environment == 'trial') {
        //   uni.reLaunch({
        //     url:'/pages/item/search?cateCode=7962&title=不凡甄选&navId=4503'
        //   })
        // }

      },
      formatDate(date) {
        let data = date.slice(5, 10).replace('-', '月') + '日' + date.slice(11, 16)
        return data
      },
      onShareAppMessage: function(res) {
        const goodsPath = this.params.shareCardLink || '/pages/item/item?id=' + this.params.goodsId + '&valueId=' +
          this.params.valueId;
        let name = this.params.shareText || this.params.itemName
        let url = this.params.shareCardPicUrl || this.params.url
        this.$commonSensors.sensorsPageShare()
				this.$sr.setContext({ share_title: name || 'THE MACALLAN EBOUTIQUE麦卡伦' });
        return this.$commonFunction.commonShare(res, name, goodsPath, url);
      },
    }
  }
</script>

<style lang="less">
  .contentBox {
    padding-top: 50rpx;

    .pageTitle {
      text-align: center;
      font-size: 28rpx;
      margin-bottom:45rpx;
      font-weight: bold;
    }

    .textBox {
      text-align: center;
      margin-bottom: 7rpx;
      font-size: 27rpx;
			padding: 0 20rpx;
      font-weight: bold;

      &.mb46{
        margin-bottom: 41rpx;
      }
    }
    .stextBox{
      font-size: 25rpx;
      padding: 0 40rpx 0 40rpx;
      text-align: justify;
      text-align-last:center;
      line-height:36rpx;
    }
    .imgBox {
      padding-top: 70rpx;
      width: 556rpx;
      margin: auto;

      image {
        width: 100%;
        display: block;
      }
    }

    .imgTitle {
      padding-top: 22rpx;
      width: 560rpx;
      margin: auto;
      text-align: center;
      font-size: 28rpx;
      overflow: hidden;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      line-height: 36rpx;
    }
  }

  .btnBox {
    display: flex;
    justify-content:center;
    margin: auto;
    padding-top: 45rpx;
    margin-bottom:220rpx;

    .item {
      background-color: #fff;
      color: #000;
      padding: 0;
      margin: 0;

      &.button{
        margin-right:190rpx;
        width: auto;
      }

      .icon {
        width: 44rpx;
        height: 44rpx;
        margin: 0 auto 10rpx;

        image {
          display: block;
          width: 100%;
        }
      }
    }
  }

  .bottomBtn {
    position: fixed;
    bottom: 0;
    left: 0;
    margin: 100rpx 0 0;
    background-color: #fff;
    width: 100%;
    padding-bottom: 0rpx;

    &.fix-iphonex-button {
      padding-bottom: 50rpx;
    }

    .btn100 {
      font-size: 32rpx;
      background-color: #000;
      color: #fff;
      text-align: center;
      padding: 30rpx 0;
      width: 100%;
    }
  }

  .fontTo {
    margin-top: -30rpx;
  }
  .bold{
    font-weight: bold;
  }
</style>
